<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //常用的键盘事件：onkeyup键盘松开时触发  onkeydown键盘被按下时触发  onkeypress键盘被按下时触发
        //keydown要比keypress先执行
        //keypress的时候功能键不起作用  比如shift等
        document.addEventListener('keyup',function(){
            console.log('键盘的键松开了');
        })
        document.addEventListener('keydown',function(){
            console.log('键盘的键按下了keydown');
        })
        document.addEventListener('keypress',function(){
            console.log('键盘的键按下了keypress');
        })
    </script>
</body>
</html>